/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-20
*/
package com.rzico.order.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;

/**
 * <pre>
 *   出入库单项数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@Table(name = "wx_warehouse_item")
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WarehouseItem{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "成本价" )
    protected java.math.BigDecimal cost;

    @ApiModelProperty(value = "商品名称" )
    protected String name;

    @ApiModelProperty(value = "采购价" )
    protected java.math.BigDecimal price;

    @ApiModelProperty(value = "数量" )
    protected BigDecimal quantity;

    @ApiModelProperty(value = "商品编号" )
    protected String sn;

    @ApiModelProperty(value = "商品规格" )
    protected String spec;

    @ApiModelProperty(value = "单位")
    protected String unit;

    @ApiModelProperty(value = "商品规格" )
    protected String thumbnail;

    @ApiModelProperty(value = "商品规格" )
    protected Long productId;

    @ApiModelProperty(value = "出入库单" )
    protected Long warehouseId;

    @ApiModelProperty(value = "所在仓库" )
    protected Long shopId;

    @ApiModelProperty(value = "类型 {0.产品,1:套餐,2:水票,3.压桶}" )
    protected Integer subType;

    @ApiModelProperty(value = "活动折扣金额")
    protected java.math.BigDecimal discount;

    @ApiModelProperty(value = "销项税率（%）" )
    protected java.math.BigDecimal tax;

    @ApiModelProperty(value = "企业编码")
    protected Long enterpriseId;

    @ApiModelProperty(value = "最小单位商品编码")
    protected Long mainProductId;

    @ApiModelProperty(value = "与最小单位的转换系数")
    protected BigDecimal mainProductQuantity;

    @ApiModelProperty(value = "商品金额")
    public BigDecimal getAmount(){
        return this.getPrice().multiply(this.getQuantity()).setScale(2,BigDecimal.ROUND_HALF_DOWN);
    }

    @ApiModelProperty(value = "实收金额")
    public BigDecimal getSubTotal(){
        return this.getPrice().multiply(this.getQuantity()).subtract(getDiscount()).setScale(2,BigDecimal.ROUND_HALF_DOWN);
    }
}
